package Time.TimeJDK8.Calendar类;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
import java.time.MonthDay;

//年月日
public class LocalDateIntroduce {
    public static void main(String[] args) {
        //1.获取当前时间的日历对象《包含 年月日)
        LocalDate nowDate = LocalDate.now();
        //System.out.printin("今天的日期：“+ nowDate);
        System.out.println("=====================================");
        //2.获取指定的时间的日历对象
        LocalDate IdDate = LocalDate.of(2023,1, 1);
        System.out.println("指定日期："+IdDate);
        System.out.println("=====================================");

        //3.get系列方法获取口历中的每一个属性值
        //获取年
        int year =IdDate.getYear();
        System.out.println("year:"+ year);
        //获取月
        //方式一：
        Month m = IdDate.getMonth();
        System.out.println(m);
        System.out.println(m.getValue());
        System.out.println("=====================================");
        //方式二：
        int month = IdDate.getMonthValue();
        System.out.println("month: "+ month);

        //获取日
        int day = IdDate.getDayOfMonth();
        System.out.println("day:"+ day);

        //获取一年的第几天
        int dayOfYear = IdDate.getDayOfYear();
        System.out.println("day0fYear:"+ dayOfYear);

        //获取星期
        DayOfWeek dayOfWeek = IdDate.getDayOfWeek();
        System.out.println(dayOfWeek);
        System.out.println(dayOfWeek.getValue());

        //is开头的方法表示判断
        System.out.println(IdDate.isBefore(IdDate));
        System.out.println(IdDate.isAfter(IdDate));

        //with开头的方法表示修改，只能修改年月日
        LocalDate withLocalDate =IdDate.withYear(2000);
        System.out.println(withLocalDate);

        //minus开头的方法表示减少，只能减少年月日
        LocalDate minusLocalDate =IdDate.minusYears(1);
        System.out.println(minusLocalDate);

        //plus开头的方法表示增加，只能增加年月日
        LocalDate plusLocalDate =IdDate.plusDays(1);
        System.out.println(plusLocalDate);

        //-----
        //判断今天是否是你的生日
        LocalDate birDate = LocalDate.of(2000, 1, 1);
        LocalDate nowDate1 = LocalDate.now();
        MonthDay birMd = MonthDay.of(birDate.getMonthValue(), birDate.getDayOfMonth());
        MonthDay nowMd = MonthDay.from(nowDate1);
        System.out.println("今天是你的生日吗?"+ birMd.equals(nowMd));//今天是你的生日吗？
    }
}
